function Reader(fileId,fileName,qrcodeUrl,dtype,docUrl,pageUrl,dataUrl) {
	this.fileId = fileId;
	this.fileName = fileName;
	this.qrcodeUrl = qrcodeUrl;
	this.dtype = dtype;
	this.docUrl = docUrl;
	this.pageUrl = pageUrl;
	this.dataUrl = dataUrl;
	this.viewSDK = null;
	this.m_index = 0;
	this.zoomnum = 0;
}

Reader.prototype.drawview = function(){
	var divid = document.getElementById("MainFrame_ViewContainer_PageContainer_0");
	this.RenderPage(0,divid, 0, 0, this.GetPageSize(0)[0], this.GetPageSize(0)[1], 0);
	var viewarea = document.getElementById("jspviewarea");
	$("#totalPages").html("/" + this.GetPageCount());
	
	if(this.GetPageCount() == 1){
		$("#btnnext").removeClass("fwr_toolbar_btn fwr_toobar_image_btn fwr_toobar_next_page_nor");
		$("#btnnext").addClass("fwr_toobar_image_btn fwr_toobar_next_page_dis");
		
		$("#btnlast").removeClass("fwr_toolbar_btn fwr_toobar_image_btn fwr_toobar_last_page_nor");
		$("#btnlast").addClass("fwr_toobar_image_btn fwr_toobar_last_page_dis");
	}
	//绑定滚动效果 // set scroll bar scroll handler for viewer
	viewarea.addEventListener("mousewheel", Reader.prototype.OnViewerMouseWheelScroll, false);
	viewarea.addEventListener("DOMMouseScroll", Reader.prototype.OnViewerMouseWheelScroll, false);
	viewarea.addEventListener("scroll",  Reader.prototype.OnViewerMouseWheelScroll, false);
};

Reader.prototype.getPageCount = function(){
	return this.viewSDK.GetPageCount();
};

Reader.prototype.CreateDocViewHtml = function(){//
	var str = "<div style=\"position: relative; height: 1056px; width: 816px; margin-left: 155px;\" id=\"MainFrame_ViewContainer_PageContainer_" + 0 + "\" class=\"fwr_page\">";
	$(".jspPaneTree").append(str);
	this.changeCss(11);
	this.viewSDK = new ViewSDK(this.fileId,this.docUrl,this.pageUrl,this.dataUrl);
	this.viewSDK.OpenPDDocument(Reader.prototype.drawview);
};

Reader.prototype.goToPage = function(index){
	var pageCount = this.getPageCount();
	if(index < 0 || index >= pageCount){
		return;
	}
	var divid = document.getElementById("MainFrame_ViewContainer_PageContainer_" + index);
	$("#MainFrame_ViewContainer_PageContainer_" + this.m_index).css("display", "none");
	
	if(index > 0 && index < pageCount - 1){
		this.changeCss(12);
	}else if(index  == 0){
		this.changeCss(11);
	}else if(index == pageCount - 1){
		this.changeCss(12);
		this.changeCss(21);
	}
	var tmp = document.getElementById("canvas" + index);
	if(tmp == null){
		this.viewSDK.RenderPage(index,divid, 0, 0, this.viewSDK.GetPageSize(0)[0] + (this.zoomnum * 70), this.viewSDK.GetPageSize(0)[1] + (this.zoomnum * 70), 0);
	}else{
		$("#MainFrame_ViewContainer_PageContainer_" + index).css("display", "block");
		if(this.zoomnum != 0){
			this.viewSDK.RenderPage(index,divid, 0, 0, this.viewSDK.GetPageSize(0)[0] + (this.zoomnum * 70), this.viewSDK.GetPageSize(0)[1] + (this.zoomnum * 70), 0);
		};
	}
	this.m_index = index;
};

Reader.prototype.goToFirstPage = function(){
	var pageCount = this.getPageCount();
	var divid = document.getElementById("MainFrame_ViewContainer_PageContainer_0");
	$("#MainFrame_ViewContainer_PageContainer_" + this.m_index).css("display", "none");
	if(pageCount != 1){
		this.changeCss(22);
	}
	this.changeCss(11);
	this.m_index = 0;
	var tmp = document.getElementById("canvas0");
	if(tmp == null){
		var str = "<div style=\"position: relative; height: 1056px; width: 816px; margin-left: 155px;\" id=\"MainFrame_ViewContainer_PageContainer_" + i + "\" class=\"fwr_page\">";
		$(".jspPaneTree").append(str);
		this.viewSDK.RenderPage(0, divid, 0, 0, this.viewSDK.GetPageSize(0)[0] + (this.zoomnum * 70), this.viewSDK.GetPageSize(0)[1] + (this.zoomnum * 70), 0);
	}else{
		$("#MainFrame_ViewContainer_PageContainer_0").css("display", "block");
		if(this.zoomnum != 0){
			this.viewSDK.RenderPage(0, divid, 0, 0, this.viewSDK.GetPageSize(0)[0] + (this.zoomnum * 70), this.viewSDK.GetPageSize(0)[1] + (this.zoomnum * 70), 0);
		};
	};
};

Reader.prototype.goToPreviousPage = function(index){
	if(index < 0){
		return;
	}
	var divid = document.getElementById("MainFrame_ViewContainer_PageContainer_" + index);
	$("#MainFrame_ViewContainer_PageContainer_" + (index + 1)).css("display", "none");
	var tmp = document.getElementById("canvas" + index);
	if(tmp == null){
		this.viewSDK.RenderPage(index,divid, 0, 0, this.viewSDK.GetPageSize(0)[0] + (this.zoomnum * 70), this.viewSDK.GetPageSize(0)[1] + (this.zoomnum * 70), 0);
	}else{
		$("#MainFrame_ViewContainer_PageContainer_" + index).css("display", "block");
		if(this.zoomnum != 0){
			this.viewSDK.RenderPage(index,divid, 0, 0, this.viewSDK.GetPageSize(0)[0] + (this.zoomnum * 70), this.viewSDK.GetPageSize(0)[1] + (this.zoomnum * 70), 0);
		};
	}
	if(index != 0){
		this.m_index--;
		this.changeCss(22);
	}else{
		this.m_index = 0;
		this.changeCss(11);
	};
};

Reader.prototype.goToNextPage = function(index){
	var pageCount = this.getPageCount();
	if(index >= pageCount){
		return;
	}
	var divid = document.getElementById("MainFrame_ViewContainer_PageContainer_" + index);
	$("#MainFrame_ViewContainer_PageContainer_" + (index - 1)).css("display", "none");
	
	if(index == (pageCount - 1)){
		this.changeCss(21);
	}
	this.m_index++;
	if(this.m_index >= 1){
		this.changeCss(12);
	}
	var tmp = document.getElementById("canvas" + index);
	if(tmp == null){
		this.viewSDK.RenderPage(index,divid, 0, 0, this.viewSDK.GetPageSize(0)[0] + (this.zoomnum * 70), this.viewSDK.GetPageSize(0)[1] + (this.zoomnum * 70), 0);
	}else{
		$("#MainFrame_ViewContainer_PageContainer_" + index).css("display", "block");
		if(this.zoomnum != 0){
			this.viewSDK.RenderPage(index,divid, 0, 0, this.viewSDK.GetPageSize(0)[0] + (this.zoomnum * 70), this.viewSDK.GetPageSize(0)[1] + (this.zoomnum * 70), 0);
		};
	};
};

Reader.prototype.goToLastPage = function(){
	var pageCount = this.viewSDK.GetPageCount();
	var divid = document.getElementById("MainFrame_ViewContainer_PageContainer_" + (pageCount - 1));
	$("#MainFrame_ViewContainer_PageContainer_" + this.m_index).css("display", "none");

	this.changeCss(21);
	if(pageCount != 1){
		this.changeCss(12);
	}
	this.m_index = pageCount - 1;
	var tmp = document.getElementById("canvas" + this.m_index);
	if(tmp == null){
		this.viewSDK.RenderPage(this.m_index, divid, 0, 0, this.viewSDK.GetPageSize(0)[0] + (this.zoomnum * 70), this.viewSDK.GetPageSize(0)[1] + (this.zoomnum * 70), 0);
	}else{
		$("#MainFrame_ViewContainer_PageContainer_" + this.m_index).css("display", "block");
		if(this.zoomnum != 0){
			this.viewSDK.RenderPage(this.m_index, divid, 0, 0, this.viewSDK.GetPageSize(0)[0] + (this.zoomnum * 70), this.viewSDK.GetPageSize(0)[1] + (this.zoomnum * 70), 0);
		};
	};
};

Reader.prototype.changeCss = function(type){
	if(type == 11){
		$("#btnpre").removeClass("fwr_toobar_image_btn fwr_toobar_prev_page_nor fwr_toolbar_btn");
		$("#btnpre").addClass("fwr_toobar_prev_page_dis fwr_toobar_image_btn");
		
		$("#btnfirst").removeClass("fwr_toobar_image_btn fwr_toobar_first_page_nor fwr_toolbar_btn");
		$("#btnfirst").addClass("fwr_toobar_image_btn fwr_toobar_first_page_dis");
	}else if(type == 12){
		$("#btnpre").removeClass("fwr_toobar_prev_page_dis fwr_toobar_image_btn");
		$("#btnpre").addClass("fwr_toobar_image_btn fwr_toobar_prev_page_nor fwr_toolbar_btn");
		
		$("#btnfirst").removeClass("fwr_toobar_image_btn fwr_toobar_first_page_dis");
		$("#btnfirst").addClass("fwr_toobar_image_btn fwr_toobar_first_page_nor fwr_toolbar_btn");
	}else if(type == 21){
		$("#btnnext").removeClass("fwr_toolbar_btn fwr_toobar_image_btn fwr_toobar_next_page_nor");
		$("#btnnext").addClass("fwr_toobar_image_btn fwr_toobar_next_page_dis");
		
		$("#btnlast").removeClass("fwr_toolbar_btn fwr_toobar_image_btn fwr_toobar_last_page_nor");
		$("#btnlast").addClass("fwr_toobar_image_btn fwr_toobar_last_page_dis");
	}else if(type == 22){
		$("#btnnext").removeClass("fwr_toobar_image_btn fwr_toobar_next_page_dis");
		$("#btnnext").addClass("fwr_toolbar_btn fwr_toobar_image_btn fwr_toobar_next_page_nor");
		
		$("#btnlast").removeClass("fwr_toobar_image_btn fwr_toobar_last_page_dis");
		$("#btnlast").addClass("fwr_toolbar_btn fwr_toobar_image_btn fwr_toobar_last_page_nor");
	}
};

Reader.prototype.zoomIn = function(){//放大
	var divid = document.getElementById("MainFrame_ViewContainer_PageContainer_" + this.m_index);
	this.zoomnum++;
	if(this.zoomnum <= 5){
		this.viewSDK.RenderPage(this.m_index, divid, 0, 0, this.viewSDK.GetPageSize(0)[0] + (this.zoomnum * 70), this.viewSDK.GetPageSize(0)[1] + (this.zoomnum * 70), 0);
	}
	
	if(this.zoomnum > 5){
		this.zoomnum = 5;
	};
};

Reader.prototype.zoomOut = function(){
	var divid = document.getElementById("MainFrame_ViewContainer_PageContainer_" + this.m_index);
	this.zoomnum--;
	if(this.zoomnum >= -5){
		this.viewSDK.RenderPage(this.m_index, divid, 0, 0, this.viewSDK.GetPageSize(0)[0] + (this.zoomnum * 70), this.viewSDK.GetPageSize(0)[1] + (this.zoomnum * 70),0);
	}
	
	if(this.zoomnum < -5){
		this.zoomnum = -5;
	};
};
Reader.prototype.getCurrentPage = function(){
	return this.m_index;
};
Reader.prototype.OnViewerMouseWheelScroll = function(event) {
    if(event.mozMovementY >= 595 * (this.m_index)){
    	
    }
	if (event.ctrlKey) {
		event.preventDefault();
		event.stopPropagation();
	}
};